import axios from 'axios';

let request = axios.create({
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  withCredentials: true
})
request.interceptors.response.use(
  response=> {
    return response.data;
  },
  error => {
    if (401 === error.response.status) {
      // 未登录
      sessionStorage.removeItem('phone')
      sessionStorage.removeItem('user_name')
      sessionStorage.removeItem('avatar')
      sessionStorage.removeItem('is_admin')
      window.location = '/';
    } else if (403 === error.response.status) {
      alert("权限不足！")
      location.href = 'http://localhost:8080/#/customer/customerDish'
    }
  }
)
export default request
